package acwing.前缀和与差分;

import java.util.Scanner;

/**
 * @description:
 * @author: qian
 * @createDate: 2021/11/12
 */
public class chafen_juzhen {

    private static final int N=1010;

    public static void insert(int x1,int y1,int x2,int y2,int c,int [][]b){
        b[x1][y1]+=c;
        b[x2+1][y1]-=c;
        b[x1][y2+1]-=c;
        b[x2+1][y2+1]+=c;
    }
    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), m = in.nextInt();//n行m列
        int q = in.nextInt();//q次运算

        int[][] a = new int[N][N];
        int[][] b = new int[N][N];

        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= m; j++)
                a[i][j] = in.nextInt();


        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= m; j++)
                insert(i, j, i, j, a[i][j], b);

        while (q-- != 0) {

            int x1 = in.nextInt(), y1 = in.nextInt(), x2 = in.nextInt(), y2 = in.nextInt(), c = in.nextInt();
            insert(x1, y1, x2, y2, c, b);


        }
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= m; j++) {
                b[i][j] += b[i - 1][j] + b[i][j - 1] - b[i - 1][j - 1];

            }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                System.out.print(b[i][j] + " ");
            }
            System.out.println();
        }
    }
}
